package cn.jboa.dao.impl;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.util.List;

import org.apache.struts2.components.template.FreemarkerTemplateEngine;
import org.springframework.stereotype.Repository;

import cn.jboa.base.BaseDaoImpl;
import cn.jboa.dao.IDepartmentDAO;
import cn.jboa.entity.Department;
@SuppressWarnings("unchecked")
@Repository
public class DepartmentDAOImpl extends BaseDaoImpl<Department> implements IDepartmentDAO{
	@Override
	public List<Department> findTopList() {
		return getSession().createQuery("FROM Department d where d.parent is null").list();
	}

	@Override
	public List<Department> findChildren(Integer parentId) {
		return getSession().createQuery("FROM Department d where d.parent.id=?")
				.setParameter(0, parentId).list();
		
	}

	@Override
	public void addDept(Department dept) {
		save(dept);
	}
   
}
